// pages/map/index.js
Page({

    /**
     * 页面的初始数据
     */
    data: {
      latitude: 0,
      longitude: 0,
      markers: [{
        latitude: 0,
        longitude: 0,
        iconPath: '../../images/location.png',
        width: 32,
        height: 32,
      }],
      address: '',
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad() {
      wx.$model.home.sysConfig().then(res => {
        if (res) {
          let location = res.hospital_location.split(',')
          let longitude = parseFloat(location[0])
          let latitude = parseFloat(location[1])

          this.setData({
            longitude: longitude,
            latitude: latitude,
            markers: [{
              latitude: latitude,
              longitude: longitude,
              iconPath: '../../images/location.png',
              width: 32,
              height: 32,
            }],
            address: res.hospital_addr
          })
        }
      })
    },

    openLocation () {
      wx.openLocation({
        address: this.data.address,
        latitude: this.data.latitude,
        longitude: this.data.longitude,
      })
    }
})